﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vds2465Telegrams;

namespace Vds2465Parser
{
	internal static class GenParse_UserData_51_ManufacturerId
	{
		#region internal methods

		internal static byte[] GenerateBytes(UserData userData)
		{
			if (userData is UserData_51_ManufacturerId)
			{
				UserData_51_ManufacturerId userData51 = userData as UserData_51_ManufacturerId;
				return GenParse_UserData_AsciiBytes.GenerateBytes(UserData.UserData51ManufacturerId, userData51.GetCopyOfAsciiBytes(), UserData_51_ManufacturerId.MaxNrOfChars);
			}

			// TODO handle error - wrong UserData type
			byte[] userDataBytes = null;

			return userDataBytes;
		}

		internal static bool ParseBytes(byte[] userDataBytes, out UserData userData51ManufacturerId, out int consumedBytes)
		{
			userData51ManufacturerId = null;
			consumedBytes = 0;
			byte[] manufacturerIdBytes;

			bool bRetVal = GenParse_UserData_AsciiBytes.ParseBytes(userDataBytes, UserData.UserData51ManufacturerId, out manufacturerIdBytes, out consumedBytes);
			if (bRetVal)
			{
				userData51ManufacturerId = new UserData_51_ManufacturerId(manufacturerIdBytes);
			}
						
			return bRetVal;
		}

		#endregion internal methods
	}
}
